import { getDefaultFields } from '../utils';
// import { DataTypes } from 'sequelize/types';


// DataTypes
module.exports = (app: Egg.Application) => {
	const DataTypes = app.Sequelize;

	const Model = app.model.define('nav', {
		id: {
			type: DataTypes.INTEGER({length: 8}).UNSIGNED,
			allowNull: false,
			primaryKey: true,
			autoIncrement: true
		},
		name: {
			type: DataTypes.STRING(255),
			allowNull: false,
			defaultValue: ''
		},
		type: {
			type: DataTypes.STRING(20),
			allowNull: false,
			defaultValue: 'navigateTo'
		},
		url: {
			type: DataTypes.STRING(255),
			allowNull: true,
			defaultValue: ''
		},
		icon: {
			type: DataTypes.STRING(255),
			allowNull: false,
			defaultValue: ''
		},
		category_id: {
			type: DataTypes.INTEGER.UNSIGNED,
			allowNull: true,
			defaultValue: null
		},
		sort: {
			type: DataTypes.INTEGER.UNSIGNED,
			allowNull: true,
			defaultValue: 0,
			comment: '排序'
		},
        status: {
            type: DataTypes.INTEGER({length: 1}).UNSIGNED,
            allowNull: true,
            defaultValue: 0,
            comment: '0-> 停用，1-> 启用'
		},
		param: {
			type: DataTypes.STRING(500),
			allowNull: true,
            comment: '参数值'

		},
		target: {
			type: DataTypes.STRING(20),
			comment: '调转目标',
			allowNull: true
		},
		...getDefaultFields()
	}, {
		tableName: 'nav',
		timestamps: false
	});

	Model.sync({ alter: true });
	
	// Model.associate = function() {
	// }

	return Model;
};
